home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / mus / play / multiplsr.lha / Bovs / Bovs.asm next >
Assembly Source File  |  1992-04-10  |  20KB  |  648 lines

  1. ********************************************************************
  2. *
  3. *                                 Bovs.asm
  4. *                        Bryan's Overlay Supervisor
  5. *                       Copyright (C) 1991 Bryan Ford
  6. *
  7. ********************************************************************
  8. * $Id: Bovs.asm,v 1.2 92/04/10 15:36:56 BAF Exp $
  9. * Assemble with A68k version >2.71
  10.  
  11. * If OVERLAY is 0, the overlay system is disabled.
  12. OVERLAY set     1
  13.  
  14. * If DETACH is 0, the startup code loses the ability to auto-detach.
  15. DETACH  set     1
  16.  
  17.         include "exec/types.i"
  18.         include "exec/tasks.i"
  19.         include "exec/libraries.i"
  20.         include "exec/alerts.i"
  21.         include "exec/memory.i"
  22.         include "exec/execbase.i"
  23.         include "exec/funcdef.i"
  24.         include "exec/exec_lib.i"
  25.         include "dos/dos.i"
  26.         include "dos/dosextens.i"
  27.         include "dos/rdargs.i"
  28.         include "dos/dos_lib.i"
  29.         include "workbench/startup.i"
  30.         include "bry/macros.i"
  31.         include "bry/memman.i"
  32.  
  33. * Main program must define these:
  34.         xref    _stack                  ; Stack size for subprocess when run from CLI
  35.         xref    _progname               ; Pointer to program name string
  36.         xref    _priority               ; Priority for process detached from CLI
  37.  
  38.         xref    _argtemplate            ; Pointer to ReadArgs template for 2.0 startup
  39.         xref    _argexthelp             ; Pointer to ReadArgs extended help string
  40.         xref    _argarray               ; ReadArgs array of longwords to fill
  41.  
  42.         xdef    LockOverlay,UnlockOverlay,ResCall
  43.         xdef    @LockOverlay,@UnlockOverlay,_ResCall
  44.  
  45.         IFNE    OVERLAY
  46. * OvNode - Structure used to keep track of loaded overlays
  47.  STRUCTURE      OvNode,mmn_SIZEOF       ; First a MemMan node
  48.         BPTR    on_SegList              ; SegList for node if currently loaded
  49.         UWORD   on_LockCount            ; Number of times this node is locked
  50.         LABEL   on_SIZEOF
  51.  
  52. * OvTabEntry - Offsets within the overlay table.
  53.  STRUCTURE      OvTabEntry,0
  54.         ULONG   ot_SeekOfs              ; Load file position
  55.         APTR    ot_OvNode               ; Pointer to OvNode structure
  56.         LONG    ot_dummy2
  57.         ULONG   ot_Level                ; Overlay level - always 1
  58.         ULONG   ot_Ordinate             ; Ordiinate number of node
  59.         ULONG   ot_FirstHunk            ; Position to load into in hunk table
  60.         ULONG   ot_SymbolHunk           ; Where symbol is found
  61.         ULONG   ot_SymbolOfs            ; Where in that hunk
  62.         LABEL   ot_SIZEOF
  63.         ENDC
  64.  
  65.         code    NTRYHUNK
  66.  
  67.         xref    _LinkerDB,__BSSBAS,__BSSLEN
  68.         xref    MMInit
  69.         xref    @Main,@PreStart
  70.  
  71. first:
  72.         IFNE    OVERLAY
  73.         bra     startup
  74.         cnop    0,4
  75.  
  76. * This next word serves to identify the overlay
  77. * supervisor to 'unloader'.
  78.  
  79.                 dc.l    $ABCD           ; Magic unloader cookie
  80. loaddat:
  81. loadstream      ds.l    1               ; Overlay input stream
  82. loadovtab       ds.l    1               ; Overlay table (Machine address)
  83. loadhtab        ds.l    1               ; Hunk table    (BCPL address)
  84. loadglobvec     ds.l    1               ; Global vector (Machine address)
  85.         ENDC
  86.  
  87. *** startup - Startup code to initialize the overlay system and detach CLI processes
  88. startup:
  89.         lea     _LinkerDB,a4            ; Find data segment
  90.         move.l  4,a6                    ; Find exec.library
  91.  
  92.         lea     __BSSBAS,a2             ; Clear uninitialized data
  93.         moveq   #0,d1
  94.         move.l  #__BSSLEN,d2
  95.         bra.s   12$
  96. 11$     move.l  d1,(a2)+
  97. 12$     dbf     d2,11$
  98.  
  99.         move.l  a6,_SysBase(a4)         ; Store SysBase for everyone else
  100.         move.l  sp,origsp(a4)           ; Save original SP (may change later if we detach)
  101.  
  102.         movem.l d0/a0,cliargs(a4)       ; Store CLI argument line
  103.  
  104.         lea     dosname(pc),a1          ; Open dos.library
  105.         moveq   #33,d0                  ; Requires at least Kickstart 1.2
  106.         jsr     _LVOOpenLibrary(a6)
  107.         moveq   #ERROR_INVALID_RESIDENT_LIBRARY,d1
  108.         move.l  d0,_DOSBase(a4)
  109.         bz      \fatalerr
  110.  
  111.         IFNE    OVERLAY
  112.         lea     loadstream(pc),a2       ; Steal the file handle
  113.         move.l  (a2),stream(a4)
  114.         clr.l   (a2)+
  115.  
  116.         move.l  (a2)+,a5                ; Overlay data table (a5)
  117.         move.l  (a2),a3                 ; Hunk table (a3)
  118.         add.l   a3,a3
  119.         add.l   a3,a3
  120.  
  121.         move.l  -(a3),d0                ; Allocate room for a copy of both tables
  122.         add.l   -(a5),d0
  123.         subq.l  #4,d0
  124.         move.l  d0,d2
  125.         moveq   #0,d1
  126.         jsr     _LVOAllocMem(a6)
  127.         moveq   #ERROR_NO_FREE_STORE,d1
  128.         tst.l   d0
  129.         bz      \fatalerr
  130.  
  131.         move.l  d0,a0                   ; Copy hunk table
  132.         move.l  d2,(a0)+
  133.         move.l  a0,htab(a4)
  134.         move.l  (a3)+,d0
  135.         lsr.l   #2,d0
  136.         subq.l  #1+1,d0
  137. 21$     move.l  (a3)+,(a0)+
  138.         dbra    d0,21$
  139.         move.l  (a5)+,d0
  140.         move.l  (a5),d1                 ; Find first overlay data table node
  141.         lsl.l   #2,d1
  142.         add.l   a0,d1
  143.         move.l  d1,ovdtab(a4)
  144.         lsr.l   #2,d0                   ; Copy overlay table
  145.         subq.l  #1+1,d0
  146. 22$     move.l  (a5)+,(a0)+
  147.         dbra    d0,22$
  148.         move.l  a0,ovdtabend(a4)
  149.         ENDC
  150.  
  151.         jsr     MMInit                  ; Initialize the memory manager
  152.         moveq   #ERROR_NO_FREE_STORE,d1
  153.         tst.l   d0
  154.         bz      \fatalerr
  155.  
  156.         move.l  ThisTask(a6),a2         ; Find our process (a2)
  157.  
  158.         move.l  a2,a1                   ; Set our priority (save old priority and restore it later)
  159.         move.l  _priority,d0
  160.         jsr     _LVOSetTaskPri(a6)
  161.         move.b  d0,origpri(a4)
  162.         st.b    prichanged(a4)
  163.  
  164.         move.l  pr_CurrentDir(a2),olddir(a4)    ; Save the current directory
  165.  
  166.         tst.l   pr_CLI(a2)
  167.         bnz.s   \fromcli
  168.  
  169. \fromwb:
  170.         lea     pr_MsgPort(a2),a0       ; Get the startup message
  171.         move.l  a0,d2
  172.         jsr     _LVOWaitPort(a6)
  173.         move.l  d2,a0
  174.         jsr     _LVOGetMsg(a6)
  175.         move.l  d0,a3
  176.         move.l  a3,_WBenchMsg(a4)
  177.  
  178.         move.l  sm_ArgList(a3),a1       ; Use program's directory
  179.         move.l  wa_Lock(a1),d1
  180.         move.l  _DOSBase(a4),a6
  181.         jsr     _LVOCurrentDir(a6)
  182.  
  183.         moveq   #0,d0                   ; Call PreStart routine
  184.         move.l  a3,a0
  185.         jsr     @PreStart
  186.  
  187.         pea     _BExit                  ; Call the main program routine
  188.         moveq   #0,d0
  189.         move.l  a3,a0
  190.         jmp     @Main
  191.  
  192. \fromcli:
  193.         move.l  _DOSBase(a4),a6
  194.  
  195.         cmp.w   #36,LIB_VERSION(a6)     ; Use 2.0's ReadArgs if possible
  196.         blo.s   79$
  197.         moveq   #DOS_RDARGS,d1
  198.         moveq   #0,d2
  199.         jsr     _LVOAllocDosObject(a6)
  200.         move.l  d0,rdargs(a4)
  201.         bz      \doserr
  202.         move.l  d0,d3
  203.         move.l  d0,a0
  204.         move.l  _argexthelp,RDA_ExtHelp(a0)
  205.         move.l  _argtemplate,d1
  206.         move.l  #_argarray,d2
  207.         jsr     _LVOReadArgs(a6)
  208.         tst.l   d0
  209.         bz      \doserr
  210.         moveq   #-1,d0
  211.         move.l  d0,_argsparsed(a4)
  212. 79$
  213.  
  214.         movem.l cliargs(a4),d0/a0       ; Call the PreStart routine
  215.         jsr     @PreStart
  216.  
  217.         IFNE    DETACH
  218.         move.l  a2,parenttask(a4)       ; Make sure child knows where to find us
  219.  
  220.         move.l  #SIGBREAKF_CTRL_F,d7    ; Make sure CTRL-F flag is cleared
  221.         move.l  d7,d1
  222.         moveq   #0,d0
  223.         move.l  _SysBase(a4),a6
  224.         jsr     _LVOSetSignal(a6)
  225.  
  226.         move.l  pr_CurrentDir(a2),d1    ; Get an initial directory for the subprocess
  227.         move.l  _DOSBase(a4),a6
  228.         jsr     _LVODupLock(a6)
  229.         move.l  d0,dupdir(a4)
  230.  
  231.         lea     first-4(pc),a0          ; Detach the segment list
  232.         move.l  (a0),splitseg(a4)
  233.         clr.l   (a0)
  234.  
  235.         move.l  _progname,d1            ; Start the child process
  236.         move.l  _priority,d2
  237.         move.l  #cliseg,d3
  238.         lsr.l   #2,d3
  239.         move.l  _stack,d4
  240.         jsr     _LVOCreateProc(a6)
  241.         tst.l   d0
  242.         bz.b    \callmainimmed
  243.  
  244.         move.l  _SysBase(a4),a6
  245.  
  246.         tst.b   prichanged(a4)          ; Restore the CLI priority level
  247.         bz.b    \noresetpri
  248.         move.l  ThisTask(a6),a1
  249.         move.b  origpri(a4),d0
  250.         jsr     _LVOSetTaskPri(a6)
  251. \noresetpri
  252.  
  253.         move.l  d7,d0                   ; Wait for the go-ahead from the child
  254.         jsr     _LVOWait(a6)
  255.  
  256.         moveq   #0,d0                   ; Return success code immediately
  257.         rts
  258.  
  259. \callmainimmed
  260.         move.l  splitseg(a4),first-4    ; Couldn't create process - reattach and run normally
  261.         clr.l   splitseg(a4)
  262.         ENDC
  263.  
  264.         pea     _BExit                  ; Call the main program
  265.         movem.l cliargs(a4),d0/a0
  266.         jmp     @Main
  267.  
  268. \doserr:
  269.         jsr     _LVOIoErr(a6)           ; Find the secondary error code
  270.         move.l  d0,d1
  271.  
  272. \fatalerr:
  273.         cmp.w   #36,LIB_VERSION(a6)     ; Display an appropriate error message
  274.         blo.b   \no20err
  275.         move.l  d1,d3
  276.         move.l  _progname,d2
  277.         jsr     _LVOPrintFault(a6)
  278.         move.l  d3,d1
  279. \no20err
  280.         moveq   #10,d0
  281. \brexit
  282.         jmp     BRExit
  283.  
  284. dosname dc.b    "dos.library",0
  285.  
  286.         code    text
  287.  
  288.         xref    MMFinish,MMAddNode,MMRemNode
  289.  
  290.         IFNE    OVERLAY
  291. *** _ovlyMgr - Entrypoint called by the linker when overlaid functions are called
  292. * d0 = Entrypoint number
  293. * a0/a1 = Parameters from caller
  294.         xdef    _ovlyMgr
  295. _ovlyMgr:
  296.         movem.l d2-d3/a0-a3/a5-a6,-(sp) ; 8 longwords
  297.  
  298.         move.l  ovdtab,a3               ; Find overlay data table node (a3)
  299.         move.l  a3,a2
  300.         lsl.w   #2,d0
  301.         adda.w  d0,a3
  302.  
  303.         move.l  ot_OvNode(a3),d0        ; See if we already know its OvNode
  304.         bnz.s   \alreadyfound
  305.  
  306.         move.l  ot_SeekOfs(a3),d0       ; Find the first entry in this node (a2)
  307.         moveq   #ot_SIZEOF,d1
  308.         bra.s   \findfirst_a
  309. \findfirst:
  310.         add.l   d1,a2
  311. \findfirst_a:
  312.         cmp.l   ot_SeekOfs(a2),d0
  313.         bne.s   \findfirst
  314.  
  315.         move.l  ot_OvNode(a2),d0        ; See if the OvNode is already allocated
  316.         bnz.s   \alreadyallocated
  317.  
  318. \retryalloc:
  319.         moveq   #on_SIZEOF,d0           ; Allocate the OvNode
  320.         move.l  #MEMF_PUBLIC!MEMF_CLEAR,d1
  321.         move.l  4,a6
  322.         jsr     _LVOAllocMem(a6)
  323.         move.l  d0,ot_OvNode(a2)        ; Store the OvNode in the first OvTabEntry
  324.         bz.s    \retryalloc             ; FIXME: Shouldn't there be a better way?
  325.  
  326.         move.l  d0,a0                   ; Initialize the node
  327.         lea     getridfunc(pc),a1
  328.         move.l  a1,mmn_GetRidFunc(a0)
  329.         move.l  a0,mmn_GetRidData(a0)
  330.  
  331. \alreadyallocated:
  332.         move.l  d0,ot_OvNode(a3)        ; Store OvNode into current OvTabEntry
  333.  
  334. \alreadyfound:
  335.         move.l  d0,a5                   ; OvNode into (a5)
  336.  
  337.         move.l  a5,a1                   ; Lock this node in memory during the call
  338.         bsr     lockoverlay
  339.  
  340.         move.l  on_SegList(a5),d0       ; See if the code is loaded
  341.         bnz     \alreadyloaded
  342.  
  343.         lea     rescallret(pc),a0       ; Don't load if the call is coming through ResCall
  344.         cmp.l   8*4(sp),a0
  345.         beq     \rescallquit            ; Note: D0 = 0 from above test
  346.  
  347. * Now seek to the segment and load it.  If we fail (probably because
  348. * the user removed the disk), then retry until successful.  This has
  349. * the effect of continually reprompting the user to insert the disk
  350. * until he/she obeys.
  351.         move.l  _DOSBase,a6
  352. \retryload:
  353.         move.l  stream,d1               ; Find hunk position in load file
  354.         move.l  ot_SeekOfs(a3),d2
  355.         moveq   #OFFSET_BEGINNING,d3
  356.         jsr     _LVOSeek(a6)
  357.         tst.l   d0
  358.         bmi.s   \retryload
  359.  
  360.         moveq   #0,d1                   ; Special calling format - NULL for name
  361.         move.l  htab,d2                 ; Hunk table
  362.         lsr.l   #2,d2
  363.         move.l  stream,d3               ; File handle
  364.         jsr     _LVOLoadSeg(a6)
  365.         move.l  d0,on_SegList(a5)
  366.         ble.s   \retryload
  367.  
  368. \alreadyloaded:
  369.         move.w  ot_SymbolHunk+2(a3),d1  ; Find hunk function is in
  370.         sub.w   ot_FirstHunk+2(a3),d1
  371.         bra.b   \hunkhuntin
  372. \hunkhunt
  373.         move.l  (a2),d0
  374. \hunkhuntin
  375.         lsl.l   #2,d0
  376.         move.l  d0,a2
  377.         dbra    d1,\hunkhunt
  378.  
  379.         add.l   ot_SymbolOfs(a3),a2     ; Call function (d0=OvNode, a0-a1=Passed)
  380.         move.l  a5,d0
  381.         movem.l 8(sp),a0-a1
  382.         jsr     (a2)
  383.  
  384. \rescallquit
  385.         move.l  d0,d2                   ; Unlock the node
  386.         move.l  a5,a1
  387.         bsr     unlockoverlay
  388.         move.l  d2,d0
  389.  
  390.         movem.l (sp)+,d2-d3/a0-a3/a5-a6
  391.         rts
  392.  
  393. *** LockOverlay - Lock an OvNode
  394. LockOverlay:
  395. @LockOverlay:
  396.         move.l  d0,a1
  397. lockoverlay:
  398.         addq.w  #1,on_LockCount(a1)     ; Increment nesting counter
  399.  
  400.         bra     MMRemNode               ; Take the node off the dead-list
  401.  
  402. *** UnlockOverlay - Unlock an OvNode
  403. UnlockOverlay:
  404. @UnlockOverlay:
  405.         move.l  d0,a1
  406. unlockoverlay:
  407.         subq.w  #1,on_LockCount(a1)     ; Decrement nesting counter
  408.         bz      MMAddNode               ; If zero, add to the dead-list
  409.         rts
  410.  
  411. *** ResCall - Special call routine - calls a function ONLY if it's already resident
  412. *** (if it's not resident, it returns immediately without loading the function.)
  413. * a2 = Pointer to routine to call
  414. * a0-a1 = Parameters to routine
  415. * d0 = Return value from routine if resident, zero if the routine wasn't resident.
  416. ResCall:
  417. _ResCall:
  418.         jsr     (a2)
  419. rescallret                              ; ovlyMgr watches for this return address...
  420.         rts
  421.         ENDC
  422.  
  423.         IFEQ    OVERLAY
  424. *** Fake the LockOverlay and UnlockOverlay functions for the non-overlaid versions
  425. LockOverlay:
  426. @LockOverlay:
  427. UnlockOverlay:
  428. @UnlockOverlay:
  429.         rts
  430.  
  431. ResCall:
  432. _ResCall:
  433.         jmp     (a2)
  434.         ENDC
  435.  
  436.         IFNE    DETACH
  437. *** cliseg - Fake SegList for the CLI subprocess to start at
  438.         cnop    0,4
  439.         dc.l    0                       ; Segment size
  440. cliseg: dc.l    0                       ; Link to next segment
  441.  
  442.         lea     _LinkerDB,a4            ; Find the data segment
  443.         move.l  sp,origsp(a4)           ; Save the stack pointer
  444.  
  445.         movem.l cliargs(a4),d2/a0       ; Copy the arguments
  446.         move.l  d2,d0
  447.         addq.l  #4-1,d0
  448.         andi.b  #$fc,d0
  449.         sub.l   d0,sp
  450.         move.l  sp,a1
  451.         move.l  d2,d0
  452.         bra.s   12$
  453. 11$     move.b  (a0)+,(a1)+
  454. 12$     dbra    d0,11$
  455.  
  456.         move.l  _SysBase(a4),a6         ; Signal parent task to get lost
  457.         move.l  parenttask(a4),a1
  458.         move.l  #SIGBREAKF_CTRL_F,d0
  459.         jsr     _LVOSignal(a6)
  460.  
  461.         move.l  _DOSBase(a4),a6         ; Set the initial directory
  462.         move.l  dupdir(a4),d1
  463.         jsr     _LVOCurrentDir(a6)
  464.         move.l  d0,olddir(a4)
  465.  
  466.         move.l  d2,d0                   ; Call the main program
  467.         move.l  sp,a0
  468.         jsr     @Main
  469.  
  470.         ENDC
  471.         ; fall through...
  472. *** BExit - Exit the program with a success return code
  473.         xdef    BExit,_BExit,@BExit
  474. BExit:
  475. _BExit:
  476. @BExit:
  477.         moveq   #0,d0
  478.         moveq   #0,d1
  479.         ; fall through...
  480. *** BRExit - Exit the program with a given return code
  481. * d0 = Return code
  482. * d1 = Secondary return code
  483.         xdef    BRExit,@BRExit
  484. BRExit:
  485. @BRExit:
  486.         lea     _LinkerDB,a4            ; Restore data segment
  487.         move.l  origsp(a4),sp           ; Restore SP
  488.  
  489.         movem.l d0/d1,-(sp)             ; Save returncode
  490.  
  491.         move.l  _DOSBase(a4),a6
  492.  
  493.         move.l  rdargs(a4),d1           ; Free all command-line arguments
  494.         bz.b    79$
  495.         move.l  d1,d2
  496.         jsr     _LVOFreeArgs(a6)
  497.         moveq   #DOS_RDARGS,d1
  498.         jsr     _LVOFreeDosObject(a6)
  499. 79$
  500.         IFNE    OVERLAY
  501.         move.l  stream(a4),d1           ; Close load file
  502.         bz.s    49$
  503.         jsr     _LVOClose(a6)
  504.         ENDC
  505. 49$
  506.         move.l  olddir(a4),d1           ; Return to the original current directory
  507.         bz.b    \noolddir
  508.         jsr     _LVOCurrentDir(a6)
  509. \noolddir
  510.  
  511.         move.l  dupdir(a4),d1           ; Free the initial directory
  512.         bz.s    59$
  513.         jsr     _LVOUnLock(a6)
  514. 59$
  515.         move.l  _SysBase(a4),a6
  516.  
  517.         IFNE    OVERLAY
  518.         move.l  ovdtab(a4),d0           ; Free all overlays
  519.         bz.s    19$
  520.         move.l  d0,a2
  521.         move.l  ovdtabend(a4),a3
  522. 1$      move.l  ot_OvNode(a2),d0
  523.         bz.s    18$
  524.         move.l  d0,a5
  525.         move.l  a2,a0                   ; Clear out all later nodes pointing to this same OvNode
  526.         bra.b   \clrseekin
  527. \clrseek
  528.         cmp.l   ot_OvNode(a0),a5
  529.         bne.b   \clrseekin
  530.         clr.l   ot_OvNode(a0)
  531. \clrseekin
  532.         lea     ot_SIZEOF(a0),a0
  533.         cmp.l   a3,a0
  534.         bne.b   \clrseek
  535.         move.l  a5,a0                   ; Unload the SegList
  536.         bsr     getridfunc
  537.         move.l  a5,a1
  538.         moveq   #on_SIZEOF,d0
  539.         jsr     _LVOFreeMem(a6)
  540. 18$     lea     ot_SIZEOF(a2),a2
  541.         cmp.l   a2,a3
  542.         bne.s   1$
  543. 19$
  544.         move.l  htab(a4),d0             ; Free the hunk and overlay tables
  545.         bz.s    29$
  546.         move.l  d0,a1
  547.         move.l  -(a1),d0
  548.         jsr     _LVOFreeMem(a6)
  549.         ENDC
  550. 29$
  551.         move.l  ThisTask(a6),a2         ; Find our process pointer
  552.  
  553.         tst.b   prichanged(a4)          ; Set our priority back to what it was originally
  554.         bz.b    \noresetpri
  555.         move.l  a2,a1
  556.         move.b  origpri(a4),d0
  557.         jsr     _LVOSetTaskPri(a6)
  558. \noresetpri
  559.  
  560.         move.l  _WBenchMsg(a4),d2       ; Return the Workbench message
  561.         bz.b    39$
  562.         jsr     _LVOForbid(a6)          ; Don't let Workbench unload us yet!
  563.         move.l  d2,a1
  564.         jsr     _LVOReplyMsg(a6)
  565. 39$
  566.         move.l  _DOSBase(a4),d7         ; Close dos.library
  567.         bz.b    69$
  568.         move.l  d7,a1
  569.         jsr     _LVOCloseLibrary(a6)
  570. 69$
  571.         bsr     MMFinish                ; Close down the memory manager
  572.  
  573.         move.l  (sp)+,d0                ; Pop the returncode
  574.         move.l  (sp)+,pr_Result2(a2)
  575.  
  576.         IFNE    DETACH
  577.         move.l  splitseg(a4),d1         ; Unload the program code
  578.         bz.b    99$
  579.         move.l  d7,a6
  580.         jmp     _LVOUnLoadSeg(a6)
  581.         ENDC
  582. 99$     rts
  583.  
  584.         IFNE    OVERLAY
  585. *** getridfunc - Get rid of an OvNode's SegList
  586. * a0 = OvNode
  587. * Returns:
  588. * d0 = Nonzero if we freed anything
  589. getridfunc:
  590.         movem.l a2/a6,-(sp)
  591.         move.l  a0,a2
  592.  
  593.         move.l  a0,a1                   ; No need to keep it on the dead-list
  594.         bsr     MMRemNode
  595.  
  596.         move.l  on_SegList(a2),d0       ; Un-load the SegList
  597.         bz.b    \out
  598.         move.l  d0,d1
  599.         move.l  _DOSBase,a6
  600.         jsr     _LVOUnLoadSeg(a6)
  601.         clr.l   on_SegList(a2)
  602.  
  603.         moveq   #1,d0
  604. \out    movem.l (sp)+,a2/a6
  605.         rts
  606.         ENDC
  607.  
  608.         bss     __MERGED
  609.  
  610.         xdef    _SysBase,_DOSBase,_WBenchMsg,_argsparsed
  611.  
  612. _SysBase        ds.l    1               ; System libraries
  613. _DOSBase        ds.l    1
  614.  
  615. _WBenchMsg      ds.l    1               ; If we came from Workbench
  616.  
  617. _argsparsed     ds.l    1               ; Nonzero if arguments were already parsed with ReadArgs()
  618.  
  619.                 IFNE    OVERLAY
  620. stream          ds.l    1               ; Load file handle
  621. htab            ds.l    1               ; Fake hunk table
  622. ovdtab          ds.l    1               ; Overlay data table
  623. ovdtabend       ds.l    1               ; End of overlay data table
  624.                 ENDC
  625.  
  626.                 IFNE    DETACH
  627. splitseg        ds.l    1               ; First segment after NTRYHUNK
  628.  
  629. parenttask      ds.l    1               ; Original CLI process
  630.                 ENDC
  631.  
  632. origsp          ds.l    1               ; Original sub-process SP
  633.  
  634. cliargs:                                ; Command-line arguments
  635. cliarglen       ds.l    1
  636. cliargstr       ds.l    1
  637.  
  638. dupdir          ds.l    1               ; DupLock'd directory we need to free
  639. olddir          ds.l    1               ; Original current directory supplied by the OS
  640.  
  641. rdargs          ds.l    1               ; RDArgs structure returned by ReadArgs
  642.  
  643. prichanged      ds.b    1               ; Flag: Priority changed
  644. origpri         ds.b    1               ; Original task priority
  645.  
  646.  
  647.         end
  648.